package com.zc.timedown.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zc.common.utils.DateUtils;
import com.zc.common.utils.UserThreadLocal;

import com.zc.timedown.domain.DailyReflection;
import com.zc.timedown.mapper.DailyReflectionMapper;
import com.zc.timedown.service.ApiDailyReflectionService;
import com.zc.timedown.vo.DailyReflectionStatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 每日感悟Service业务层处理
 *
 * @author zc
 * @date 2025-09-29
 */
@Service
public class ApiDailyReflectionServiceImpl extends ServiceImpl<DailyReflectionMapper, DailyReflection> implements ApiDailyReflectionService
{
    @Autowired
    private DailyReflectionMapper dailyReflectionMapper;



    /**
     * 查询每日感悟列表
     *
     * @param dailyReflection 每日感悟
     * @return 每日感悟
     */
    @Override
    public List<DailyReflection> selectDailyReflectionList(DailyReflection dailyReflection)
    {

        return dailyReflectionMapper.selectDailyReflectionList(dailyReflection);
    }

    @Override
    public DailyReflectionStatisticsVo statisticsDailyReflection() {
        Long userId = UserThreadLocal.getUserId();
        DailyReflectionStatisticsVo dailyReflectionStatisticsVo = dailyReflectionMapper.statisticsDailyReflection(userId);
        return dailyReflectionStatisticsVo;
    }

    /**
     * 新增每日感悟
     *
     * @param dailyReflection 每日感悟
     * @return 结果
     */
    @Override
    public int insertDailyReflection(DailyReflection dailyReflection)
    {
                dailyReflection.setCreateTime(DateUtils.getNowDate());
                return save(dailyReflection) == true? 1 : 0;
    }


    /**
     * 删除每日感悟信息
     *
     * @param id 每日感悟主键
     * @return 结果
     */
    @Override
    public int deleteDailyReflectionById(Long id)
    {
        return removeById(id) == true ? 1 : 0;
    }
}